Index of Functions ------------------ 1: Del_Operations Function Name ( 1): Del_Operations -------------------------------------------------------------------------------- 'Date Created: 05-Jun-2003 06:02:25 PM 'Last Updated: 14-Jun-2003 10:21:52 AM 'Created By : Cal 'Updated By : Cal FUNCTION Del_Operations as C() 'Op_list is only used to determine Op_plural based on the Op_type using STRITRAN. 'This will be done later for display purposes only. DIM Op_list as C Op_list = <<%list% Append Copy Crosstab Export Import Intersect Join Mark Post Query Subtract Summary Update Xtab %list% DIM plural_list as C Plural_list = <<%list% Appends Copies Crosstabs Exports Imports Intersects Joins Marks Posts Queries Subtracts Summaries Updates Xtabs %list% 'Create an XDialog dialog box to prompt for Operation type to be deleted. DIM Op_type as C DIM varC_result as C DELETE a_Op_type DIM a_Op_type[14] as C DIM Enum_list as C Enum_list = <<%list% Append Copy Export Import Mark Post Query Summary Update %list% 'XTAB and JOIN will be treated separately to handle special situations. 'Determine which operation types exist in this app and create list. DIM layouts_avail as C DIM Oper_type as C layouts_avail = "" FOR qx = 1 to 9 Oper_type = word( enum_list, qx, crlf()) IF eval( "a5." + Oper_type + "_enum()") <> "" layouts_avail = layouts_avail + crlf() + Oper_type END IF NEXT 'This does the same as the FOR...NEXT above except for only one operation at a time. IF a5.join_enum() <> "" layouts_avail = layouts_avail + crlf() + "Join" + crlf() + "Intersect" + crlf() + "Subtract" END IF IF a5.xtab_enum() <> "" layouts_avail = layouts_avail + crlf() + "Xtab" + crlf() + "Crosstab" END IF 'If no layouts were listed, tell user and quit. IF layouts_avail = "" ui_msg_box( "*** NO SAVED OPERATIONS FOUND ***", "No saved operations were found in this application.", 16 ) EXIT FUNCTION END IF 'Sort the string for easier selection. layouts_avail = sortsubstr( layouts_avail, crlf()) 'Set a few initial values for the XDialog. DIM head1 as C a_Op_type.initialize( Layouts_avail ) not_dbc = .T. 'Not double clicked - use to trap exit mode. head1 = "Select Operation type to be deleted." 'Display the XDialog to determine which operation type is to be deleted. varC_result = ui_dlg_box("OPERATION TYPE",<<%dlg% {region} {text=35,1head1} {endregion}; {region} [.35,15Op_type^#a_Op_type!OpType_*]; {endregion}; {line=1,0};;; <*15OK> <15Cancel> %dlg%,<<%code% IF left( a_dlg_button, 7 ) = "OpType_" Trace.WriteLn( a_dlg_button ) IF a_dlg_button = "OpType_Dblclick" not_dbc = .F. ELSE a_dlg_button = "" END IF END IF %code% ) IF varC_result = "Cancel" .or. ( varC_result = "" .and. not_dbc ) .or. Op_type = "" EXIT FUNCTION END IF 'Fix any selections that don't exactly match the real operation types. SELECT CASE Op_type = "Crosstab" Op_type = "Xtab" CASE Op_type = "Intersect" ui_msg_box( "*** NOTE ***", "An 'Intersect' is really just a special type of 'Join'." + crlf(2) + "THE LIST WILL SHOW *ALL* 'JOIN' OPERATIONS.", 48 ) Op_type = "Join" CASE Op_type = "Subtract" ui_msg_box( "*** NOTE ***", "A 'Subtract' is really just a special type of 'Join'." + crlf(2) + "THE LIST WILL SHOW *ALL* 'JOIN' OPERATIONS.", 48 ) Op_type = "Join" END SELECT 'Get the plural of the chosen operation type. DIM Op_plural as C Op_plural = STRITRAN_MULTI( Op_type, Op_list, Plural_list ) 'Create an XDialog dialog box to prompt for specific operation names to be deleted. DIM del_list as C DIM varC_result as C DIM auto_list_op_list as C auto_list_op_list = eval( "a5." + Op_type + "_enum()") IF auto_list_op_list = "" ui_msg_box( "NOTHING FOUND", "No " + Op_type + " operations were found in this application.", 16 ) EXIT FUNCTION END IF DIM temp_count as N temp_count = w_count( auto_list_op_list, crlf()) DELETE a_op_list DIM a_op_list[temp_count] as C DIM head2 as C a_op_list.initialize( auto_list_op_list ) head1 = "All highlighted " + Op_plural + " will be deleted." head2 = "NOTE: You will be prompted before each deletion." varC_result = ui_dlg_box("SELECT " +upper(Op_plural)+" TO BE DELETED",<<%dlg% {region} {text=60,1:head1}; {text=60,1:head2}; {endregion}; {region} [%M%.60,10del_list^#a_op_list]; {endregion}; {line=1,0};;; <*15OK> <15Cancel> %dlg%) IF varC_result = "Cancel" .or. varC_result = "" EXIT FUNCTION END IF 'XTAB is used with the Enum() function but CROSSTAB is required for the Delete() function. IF Op_type = "Xtab" Op_type = "Crosstab" END IF 'Delete the operations one at a time. 'The built-in Delete operation itself prompts the user for each deletion. DIM Del_cnt as N DIM to_b_deleted as C Del_cnt = w_count( del_list, crlf()) FOR qx = 1 to Del_cnt to_b_deleted = word( del_list, qx, crlf()) eval( Op_type + ".Delete('" + to_b_deleted + "')" ) 'FYI: The following also works: (why?) 'eval(Op_type+".Delete(to_b_deleted)") NEXT END FUNCTION End Function ( 1)---------------------------------------------------------------